package com.yzi.utilitys
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.filters.DisplacementMapFilter;

	public class ArrangeUtility
	{
		static public const GRAVITY_LEFT:String = "left";
		static public const GRAVITY_CENTER:String = "center";
		static public const GRAVITY_RIGHT:String = "right";
		static public const GRAVITY_TOP:String = "top";
		static public const GRAVITY_MIDDLE:String = "middle";
		static public const GRAVITY_BOTTOM:String = "bottom";
		
		public function ArrangeUtility()
		{
			throw new Error("Static Class.");
		}
		
		static public function LeftByGuide($itemList:Vector.<DisplayObject>, $hGuide:Number, $container:DisplayObjectContainer): void
		{
			for each(var item:DisplayObject in $itemList) { item.x = $hGuide - (item.getRect($container).x - item.x); }
		}
		
		static public function CenterByGuide($itemList:Vector.<DisplayObject>, $hGuide:Number, $container:DisplayObjectContainer): void
		{
			for each(var item:DisplayObject in $itemList) { item.x = $hGuide - ((item.getRect($container).width / 2) - (item.x - item.getRect($container).x)); } 
		}
		
		static public function RightByGuide($itemList:Vector.<DisplayObject>, $hGuide:Number, $container:DisplayObjectContainer): void
		{
			for each(var item:DisplayObject in $itemList) { item.x = $hGuide - (item.getRect($container).width - (item.x - item.getRect($container).x)); }
		}
		
		static public function TopByGuide($itemList:Vector.<DisplayObject>, $vGuide:Number, $container:DisplayObjectContainer): void
		{
			for each(var item:DisplayObject in $itemList) { item.y = $vGuide - (item.getRect($container).y - item.y); }
		}
		
		static public function MiddleByGuide($itemList:Vector.<DisplayObject>, $vGuide:Number, $container:DisplayObjectContainer): void
		{
			for each(var item:DisplayObject in $itemList) { item.y = $vGuide - ((item.getRect($container).height / 2) - (item.y - item.getRect($container).y)); }
		}
		
		static public function BottomByGuide($itemList:Vector.<DisplayObject>, $vGuide:Number, $container:DisplayObjectContainer): void
		{
			for each(var item:DisplayObject in $itemList) { item.y = $vGuide - (item.getRect($container).height - (item.y - item.getRect($container).y)); }
		}
	}
}